// 嗅探切换
// image没有超时机制，使用setTimeout模拟超时
// 包装image成Promise
function validateImage(url: string) {
  return new Promise((resolve, reject) => {
    const img = new Image();
    const timeout = 3000;
    // 图片加载完成执行
    img.onload = () => {
      resolve(url);
    };
    // 图片加载失败执行
    img.onerror = (e: string | Event) => {
      reject(e);
    };
    const timer = setTimeout(() => {
      clearTimeout(timer);
      reject(new Error(url + " image timeout"));
    }, timeout);
    img.src = url;
  });
}
function handleImgError(defaultUrl = "", retry = 3, evName: string) {
  const times = 0;
  const ev = new Event("bgImgError");

  document.addEventListener("");
}
export default handleImgError;
